<?php
/**
 * Created by PhpStorm.
 * User: jsb
 * Date: 2018/8/23
 * Time: 16:21
 */

namespace app\admin\controller;
use app\common\controller\AdminBase;
use app\admin\logic\loginLogical;
class Login extends AdminBase
{
    //登陆界面
    public function login()
    {
        return view();
    }
    //发送邮件和生成session
    public function sendEmail(loginLogical $loginLogical)
    {
        $result = $loginLogical -> emailCode();
        return json($result);
    }
    //验证提交的数据是不是证确
    public function validataLogin(loginLogical $loginLogical)
    {
        $data = input('post.');
        $result = $loginLogical -> validateData($data);
        if($result['status'] == 1){
            $this -> error($result['info'], '/login');
        }elseif($result['status'] == 2){
            $this -> success($result['info'], '/welcome');
        }else{
            $this -> error($result['info'], '/login');
        }

    }

}